package com.tarena.seata.web.rpc;

import com.tarena.seata.api.StockApi;
import com.tarena.seata.web.mapper.StockMapper;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class StockApiImpl implements StockApi {
    @Autowired
    private StockMapper stockMapper;
    @Transactional(rollbackFor = Exception.class)
    @Override public void reduceStock(String productCode, Integer count) {
        //System.out.println("seata全局事务id=============="+ RootContext.getXID());
        stockMapper.updateStockCountByProducerCode(productCode,count);
    }
}
